import { createRouter, createWebHistory } from "vue-router";
import Home from "@/pages/home/index.vue";
import Hospital from "@/pages/hospital/index.vue";
import Search from "@/pages/hospital/search/index.vue";
import Detail from "@/pages/hospital/detail/index.vue";
import BookingRegister from "@/pages/hospital/bookingRegister/index.vue";
import BookingInstructions from "@/pages/hospital/bookingInstructions/index.vue";
import SuspensionInfo from "@/pages/hospital/suspensionInfo/index.vue";
import RegisterStep from "@/pages/hospital/bookingRegister/register_step1.vue";
import RegisterStep2 from "@/pages/hospital/bookingRegister/register_step2.vue";
import User from "@/pages/user/index.vue";
import Certification from "@/pages/user/certification.vue";
import Order from "@/pages/user/order/order.vue";

let router = createRouter({
  history: createWebHistory(),
  routes: [
    // 首页
    {
      meta: {
        title: "首页",
      },
      name: "home",
      path: "/home",
      component: Home,
    },
    // 医院
    {
      name: "hospital",
      path: "/hospital",
      component: Hospital,
      children: [
        // 预约挂号
        {
          name: "bookingRegister",
          path: "bookingRegister",
          component: BookingRegister,
          meta: {
            title: "预约挂号",
          },
        },
        // 医院详情
        {
          name: "detail",
          path: "detail",
          component: Detail,
          meta: {
            title: "医院详情",
          },
        },
        // 查询取消
        {
          name: "search",
          path: "search",
          component: Search,
          meta: {
            title: "查询取消",
          },
        },
        // 停诊须知
        {
          name: "suspensionInfo",
          path: "suspensionInfo",
          component: SuspensionInfo,
          meta: {
            title: "停诊须知",
          },
        },

        // 预约须知
        {
          meta: {
            title: "预约须知",
          },
          name: "bookingInstructions",
          path: "bookingInstructions",
          component: BookingInstructions,
          children: [],
        },
        // 科室详情
        {
          meta: {
            title: "预约第一步",
          },
          name: "register_step1",
          path: "register_step1",
          component: RegisterStep,
        },
        {
          meta: {
            title: "预约第二步",
          },
          name: "register_step2",
          path: "register_step2",
          component: RegisterStep2,
        },
      ],
    },
    // 会员
    {
      name: "user",
      path: "/user",
      component: User,
      children: [
        // 认证
        {
          meta: {
            title: "认证管理",
          },
          name: "certification",
          path: "certification",
          component: Certification,
        },
        // 订单
        {
          meta: {
            title: "订单管理",
          },
          name: "order",
          path: "order",
          component: Order,
        },
        // 就诊人
        {
          meta: {
            title: "就诊人管理",
          },
          name: "patient",
          path: "patient",
          component: () => import("@/pages/user/patient.vue"),
        },
        // 账号信息
        {
          meta: {
            title: "账号信息",
          },
          name: "profile",
          path: "profile",
          component: () => import("@/pages/user/profile.vue"),
        },
        // 意见反馈
        {
          meta: {
            title: "意见反馈",
          },
          name: "feedback",
          path: "feedback",
          component: () => import("@/pages/user/feedback.vue"),
        },
      ],
    },
    {
      path: "/",
      redirect: "/home",
      meta: {
        title: "首页",
      },
    },
  ],
});
export default router;
